﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Migrations;
using RearLivestock.Beginning.Api.Application.Command.BreedingSow;
using RearLivestock.Common.Domains.zjy;
using RearLivestock.Common.Dtos;
using Yitter.IdGenerator;

namespace RearLivestock.Beginning.Api.Controllers
{
    /// <summary>
    /// 种母期初控制器
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class BreedingSowsController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public BreedingSowsController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 添加种母期初
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost("CreateBreedingSow")]
        public async Task<Result> CreateBreedingSow(CreateBreedingSowCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 获取种母期初
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost("GetBreedingSow")]
        public async Task<Result<PageResultDto<BreedingSowDto>>> GetBreedingSow(SearchBreedingSowCommand cmd)
        {
            return await _mediator.Send(cmd);
        }
    }
}
